﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Boggle
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Clear();
            Console.WriteLine("Boggle Server\n");

            try
            {
                int time = 60;
                string file = "..//..//..//dictionary.txt";
                string board = "TESEFHGOACAOYTIQ";

                if (args.Length < 2 | args.Length > 3)
                {
                    throw new ArgumentException("Invalid command-line arguments");
                }

                Int32.TryParse(args[0], out time);
                file = args[1];

                if (!File.Exists(file))
                {
                    throw new FileNotFoundException("Dictionary file not found");
                }

                if (args.Length == 3)
                {
                    board = args[2];
                    BoggleServer server = new BoggleServer(time, file, board);
                }
                else
                {
                    BoggleServer server = new BoggleServer(time, file);
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Environment.Exit(1);
            }

            Console.ReadLine();

            Environment.Exit(0);
        }
    }
}
